package myLearnjdk.jdk.arithmetic;

import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] arg){
        Scanner in = new Scanner(System.in);
        int[] array1 = null;
        int[] array2 = null;
        int k = 0;
         
        while (in.hasNextLine()) {//注意while处理多个case              int a = in.nextInt();
             String sre = in.nextLine().toString().trim();
             String[] strArray =  sre.split(" ");
             int size = strArray.length;
             if(strArray.length == 1){
            	 k = Integer.parseInt(strArray[0]);
             }else if(array1  == null){
            	 array1 = new int[size-1];
            	 for(int i = 1 ; i < size-1 ; i ++){
            		 array1[i] = Integer.parseInt(strArray[i]);
                 }
             }else{
            	 array2 = new int[size-1];
            	 for(int i = 1 ; i < size-1 ; i ++){
            		 array2[i] = Integer.parseInt(strArray[i]);
                 }
             }
        }
        
        int[] ret = new int[array1.length * array2.length];
        int index = 0;
        for(int i = 0 ; i < array1.length ; i++){
        	
        	for(int j = 0 ; j < array2.length ; j++){
        		if(i != j){
        			ret[index ++ ] = array1[i] + array2[j];
        		}
            }
        }
        int csize = array1.length < array2.length ? array1.length : array2.length;
        for(int i = 0 ; i < csize ; i++ ){
        	ret[index ++] = array1[i] + array2[i];
        }
        
        Arrays.sort(ret);
        if(ret[0] > ret[1]){
        	Arrays.sort(ret);
        }
        int retMin = 0;
        for(int i = 0 ; i < k ; i ++){
        	retMin += ret[i];
        	
        }
        
        System.out.println(retMin);
    }
}
